﻿@using CashFlow.Db.Entity;
@{
    ViewBag.Title = "List";
    Layout = "~/Views/Shared/_Layout3.cshtml";
    var ls = ViewBag.Orders as IList<OrderBuySellInfo>;
    var loginUser = ViewBag.LoginUser as UserInfoEntity;
}
<style type="text/css">
    .title {
        height: 40px;
        line-height: 40px;
        font-size: 20px;
        font-weight: 800;
        text-align: center;
    }

    .list {
        width: 85%;
        margin: 0px auto;
        padding-bottom: 20px;
        margin-top: 10px;
    }

    .list-item {
        background-color: white;
        border-radius: 10px;
        font-size: 16px;
        margin-top: 15px;
        padding-bottom: 5px;
    }

        .list-item:first-child {
            margin-top: 0px;
        }

    .list-item-title {
        width: 95%;
        clear: both;
        margin: 0px auto;
        margin-bottom: 5px;
        height: 40px;
        line-height: 40px;
        text-align: center;
        font-size: 20px;
        color: red;
        border-bottom: dashed 1px #cccccc;
    }

    .list-item-row {
        height: 35px;
        line-height: 35px;
    }

        .list-item-row span:first-child {
            color: #999;
            width: 100px;
            display: inline-block;
            text-align: right;
        }

        .list-item-row span:nth-child(2) {
            margin-left: 10px;
        }

        .list-item-row span:last-child {
            margin-left: 10px;
        }

    .peerInfo {
        background-color: #ff3f49;
        border-radius: 5px;
        padding: 5px 5px;
        color: white;
    }

    .stock-good {
        background-color: #ff3f49;
        border-radius: 5px;
        padding: 5px 5px;
        color: white;
    }

    .receipt {
        background-color: green;
        border-radius: 5px;
        padding: 5px 5px;
        color: white;
    }

    .voucher {
        background-color: burlywood;
        border-radius: 5px;
        padding: 5px 5px;
        color: white;
    }

    .pickup {
        background-color: #ff3f49;
        border-radius: 5px;
        padding: 5px 5px;
        color: white;
    }

    .receipt {
        background-color: #00c750;
        border-radius: 5px;
        padding: 5px 5px;
        color: white;
    }

    .receipted {
        color: #00c750;
    }

    .name {
        color: #36acf7;
    }

    .list-item-row span.buyer {
        color: #00c750;
        font-weight: bold;
    }

    .list-item-row span.seller {
        font-weight: bold;
        color: #ff3f49;
    }

    .list-item-row span.amount {
        color: #e4534e;
        font-weight: bold;
        font-size: 18px;
    }

    .paymentcode {
        width: 60px;
        height: 80px;
        overflow: hidden;
        float: left;
    }

        .paymentcode img {
            width: 60px;
            height: 80px;
        }

    .viewBigImage {
        width: 74px;
        height: 25px;
        line-height: 25px;
        background-color: #e4534e;
        color: #fff;
        font-size: 12px;
        margin-left: 20px;
        border-radius: 4px;
        text-align: center;
        float: left;
    }

    .bigImage {
        padding: 10px;
        overflow: hidden;
    }

        .bigImage img {
            width: 100%;
            height: 100%;
        }

    .bankInfo td {
        padding: 5px;
        font-size: 14px;
    }

    .voucherContainer {
        margin: 0px auto;
    }

        .voucherContainer table {
            width: 100%;
        }

        .voucherContainer td {
            padding: 5px;
            text-align: center;
        }

    .smallImg {
        width: 60px;
        height: 80px;
        border: 1px solid red;
    }

    .voucher-span-zoom {
        width: 50px;
        height: 20px;
        line-height: 20px;
        padding: 3px;
        display: inline-block;
        background-color: red;
        color: white;
    }

    .voucher-span-del {
        width: 50px;
        height: 20px;
        line-height: 20px;
        padding: 3px;
        display: inline-block;
        background-color: red;
        color: white;
    }
</style>

<div class="title">订单列表</div>
<div class="list">
    @{
        var buyerOrders = ls.Where(x => x.Buyer.Id == loginUser.Id).ToList();
        foreach (var item in buyerOrders)
        {
            <div class="list-item" isBuyer="1" sellerUserId="@item.Seller.Id" orderId="@item.Order.Id" paymentVoucherImagePath="@item.Order.PaymentVoucherImagePath">
                <div class="list-item-title">进货订单</div>
                <div class="list-item-row"><span>订单号:</span><span>@item.Order.OrderNo</span></div>
                <div class="list-item-row"><span>产品名称:</span><span>@item.Order.Name</span></div>
                <div class="list-item-row"><span>下单时间:</span><span>@item.Order.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")</span></div>
                <div class="list-item-row"><span>出货方:</span><span>@item.Seller.Name</span><span class="peerInfo">对方信息</span></div>
                <div class="list-item-row"><span>货款:</span><span class="amount">￥@item.Order.Amount</span></div>
                @if (item.Order.State == 0)
                {
                    <div class="list-item-row"><span>进货凭证:</span><span class="voucher" spanBtn="1">上传凭证</span><span class="voucher" spanBtn="2">查看凭证</span></div>
                    <div class="list-item-row" style="margin-top: 5px;"><span>确认信息:</span><span class="stock-good" spanBtn="3">确认进货</span></div>
                }
                else
                {
                    <div class="list-item-row"><span>进货凭证:</span><span class="voucher" spanBtn="2">查看凭证</span></div>
                }
                @if (item.Order.State == 2)
                {
                    <div class="list-item-row"><span>确认信息:</span><span class="pickup" spanBtn="4">我要提货</span></div>
                }
            </div>
        }
        var sellerOrders = ls.Where(x => x.Seller.Id == loginUser.Id).ToList();
        foreach (var item in sellerOrders)
        {
            <div class="list-item" isSeller="1" buyerUserId="@item.Buyer.Id" orderId="@item.Order.Id" paymentVoucherImagePath="@item.Order.PaymentVoucherImagePath">
                <div class="list-item-title" style="color: green;">出货订单</div>
                <div class="list-item-row"><span>订单号:</span><span>@item.Order.OrderNo</span></div>
                <div class="list-item-row"><span>产品名称:</span><span>@item.Order.Name</span></div>
                <div class="list-item-row"><span>下单时间:</span><span>@item.Order.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")</span></div>
                <div class="list-item-row"><span>进货方:</span><span>@item.Buyer.Name</span></div>
                <div class="list-item-row"><span>货款:</span><span class="amount">￥@item.Order.Amount</span></div>
                <div class="list-item-row"><span>出货凭证:</span><span class="voucher" spanBtn="5">查看凭证</span></div>
                @if (item.Order.State <= 1)
                {
                    <div class="list-item-row" style="margin-top: 5px;"><span>确认信息:</span><span class="receipt">确认出货</span></div>
                }
            </div>
        }
    }
</div>
<script type="text/javascript" src="~/Static/Js/order.js?rand=0123456"></script>